package com.hepinghospital.user.util

import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch

/**
 * @Description 协程帮助类
 * @Author WuJianFeng
 * @Date 2022/8/19 9:14
 */
object CoroutineUtils {

    fun launch(block: suspend () -> Unit, error: suspend (Throwable) -> Unit) = CoroutineScope(Dispatchers.Main).launch {
        try {
            block()
        } catch (error: Throwable) {
            error(error)
        }
    }
}